#ifndef HTTPHELPER_H
#define HTTPHELPER_H

#include <iostream>
#include <string_view>
#include <memory>
#include <stdexcept>
#include "curl/curl.h"

class HttpHelper
{
public:
    HttpHelper();
    ~HttpHelper();
    curl_slist* getHeader();
    std::string get(const std::string& url);
    std::string post(const std::string& url, const std::string& data);
    std::string put(const std::string& url);
    std::string header(const std::string& url);
private:
    static size_t write_callback(char* ptr, size_t size, size_t nmemb, void* userdata);

    std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> curl{ nullptr, &curl_easy_cleanup };
};

#endif // HTTPHELPER_H
